import React, {useEffect} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {PaperProvider} from 'react-native-paper';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {Provider} from 'react-redux';
import store from './app/store';
import {getTemperature} from 'app/modules/app';
import {StatusBar} from 'react-native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import BottomTabs from 'components/BottomTabs';
import {navigationRef} from 'utils/naviRef';
const Stack = createNativeStackNavigator();
function App(): JSX.Element {
  useEffect(() => {
    store.dispatch(getTemperature());
  }, []);
  return (
    <Provider store={store}>
      <GestureHandlerRootView style={{flex: 1}}>
        <PaperProvider>
          <StatusBar
            barStyle={'dark-content'}
            hidden
            translucent
            backgroundColor={'transparent'}
          />
          <NavigationContainer ref={navigationRef}>
            <Stack.Navigator
              initialRouteName="tabbar"
              screenOptions={{
                headerShown: false,
              }}>
              <Stack.Screen name="tabbar" component={BottomTabs} />
              <Stack.Screen
                name="login"
                getComponent={() => require('views/login').default}
              />
              <Stack.Screen
                name="PoliceInfo"
                options={{
                  headerShown: false,
                  headerTitle: '',
                }}
                getComponent={() =>
                  require('views/police/components/PoliceInfo').default
                }
              />
              <Stack.Screen
                name="PoliceMap"
                options={{
                  headerShown: true,
                  headerTitle: '作战部署',
                }}
                getComponent={() =>
                  require('views/police/components/PoliceMap').default
                }
              />
            </Stack.Navigator>
          </NavigationContainer>
        </PaperProvider>
      </GestureHandlerRootView>
    </Provider>
  );
}

export default App;
